package io.xxx.omni.oss.config

import com.aliyun.oss.OSS
import com.aliyun.oss.OSSClientBuilder
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
@EnableConfigurationProperties(OssProperties::class)
class OssConfig {

    @Autowired
    private lateinit var properties: OssProperties

    @Bean
    fun oss(): OSS {
        return OSSClientBuilder()
            .build(properties.endpoint, properties.accessKeyId, properties.accessKeySecret)
    }
}